Release 10.1A: OpenEdge Data Management:
SQL Reference
CREATE TABLE
Creates a table definition. A table definition consists of a set of named column definitions for data values that will be stored in rows of the table. SQL provides two forms of the
CREATE TABLEstatement.The first syntax form explicitly specifies column definitions. The second syntax form, with the
ASquery_expressionclause, implicitly defines the columns using the columns in a query expression.Syntax
owner_nameSpecifies the owner of the table. If the name is different from the user name of the user executing the statement, then the user must have DBA privileges.
table_nameNames the table you are defining.
column_definition
column_name data_typeNames a column and associates a data type with it. The column names specified must be different from other column names in the table definition. The data_type must be supported by OpenEdge.
When a table contains more than one column, a comma separator is required after each column_definition except for the final column_definition.
COLLATEIndicates the column’s case sensitivity. Note the default is
case_sensitive.case_insensitiveIndicates the column will be case insensitive. The value for
case_insensitivecan be any name ending inI(for example:BASIC_I).case_sensitiveIndicates the column will be case sensitive. The value for
case_sensitivecan be any name ending inS(for example:BASIC_S). Note thatcase_sensitiveis the default value forCOLLATE.DEFAULTSpecifies an explicit default value for a column. The column takes on the value if an
INSERTstatement does not include a value for the column. If a column definition omits theDEFAULTclause, the default value isNULL.The
DEFAULTclause accepts the following arguments:
column_constraintSpecifies a constraint that will be applied while inserting or updating a value in the associated column.
progress_column_attribute_keyword valueProgress 4GL column attribute keyword and value. See the "Syntax for 4GL Attributes" section for a list of column attribute keywords.
table_constraintSpecifies a constraint that will be applied while inserting or updating a row in the table.
AREA area_nameSpecifies the name of the storage area where data stored in the table is to be stored.
If the specified area does not exist, the database returns an error. If you do not specify an area, the default area is used.
progress_table_attribute_keyword valueProgress 4GL table attribute keyword and value. See the "Syntax for 4GL Attributes" section for a list of table attribute keywords.
AS query_expressionSpecifies a query expression to use for the data types and data values of the table’s columns. The types and lengths of the columns of the query expression result become the types and lengths of the respective columns in the table created. The rows in the resultant set of the query expression are inserted into the table after creating the table. In this form of the
ExamplesCREATE TABLEstatement, column names are optional. If omitted, the names of the table’s columns are taken from the column names of the query expression.In the following
CREATE TABLEsupplier_item example, the user issuing theCREATE TABLEstatement must haveREFERENCESprivilege on theitemnocolumn of the tablejohn.item:
The table will be created in the current owner schema.
The following
CREATE TABLEstatement explicitly specifies a table owner,gus:
The following example shows the
ASquery_expressionform ofCREATE TABLEto create and load a table with a subset of the data in the customer table:
The following example includes a
NOT NULLcolumn constraint andDEFAULTclauses for column definitions:
The following example shows how to create a table with two columns, both of which have 4GL descriptions and column labels specified:
The table itself has a description specified, and will be created as hidden.
Authorization
Must have
DBAprivilege,RESOURCEprivilege orSELECTprivilege.Related statements
DROP TABLE
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |